package com.example.rfidserver.consume.subactivity.subactivity_siteconsume;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.rfidserver.R;
import com.example.rfidserver.dao.ConsumeDao;
import com.example.rfidserver.dao.TicketDao;
import com.example.rfidserver.status.FailActivity;
import com.example.rfidserver.status.SuccessActivity;
import com.example.rfidserver.ticket.subactivity.TicketAddActivity;

public class AddService extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_service);
    }

    public void onClick(View view){

        //得到界面上的值
        TextView service_Item_name_tv =(TextView)findViewById(R.id.service_Item_name);
        TextView service_integral_tv = (TextView)findViewById(R.id.service_integral);
        String service_Item_name = service_Item_name_tv.getText().toString();
        String service_integral = service_integral_tv.getText().toString();
        ConsumeDao consumeDao =  new ConsumeDao();
        int i = consumeDao.addOneService(service_Item_name, service_integral);
        //执行成功，跳转到成功页面
        if(i!=0){
            Intent intent = new Intent(AddService.this, SuccessActivity.class);
            startActivity(intent);
        }else{
            Intent intent = new Intent(AddService.this, FailActivity.class);
            startActivity(intent);
        }

    }
}
